<?php

class ControllerCommonHeader extends Controller
{
    public function index()
    {
        $this->document->setTitle($this->config->get('config_title'));
        $this->document->setDescription($this->config->get('config_meta_description'));

        $this->data['heading_title'] = $this->config->get('config_title');

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
        } else {
            $this->template = 'default/template/common/header.tpl';
        }

        $this->language->load('common/header');
        $this->data['text_home'] = $this->language->get('text_home');
        $this->data['text_deal_travel'] = $this->language->get('text_deal_travel');
        $this->data['text_deal_hotel'] = $this->language->get('text_deal_hotel');
        $this->data['text_custom_tour'] = $this->language->get('text_custom_tour');

        if (isset($_REQUEST['redirect'])) {
            $this->data['redirectUrl'] = $_REQUEST['redirect'];
        } else {
            $this->data['redirectUrl'] = '';
        }

        $this->response->setOutput($this->render());
    }

    public function language()
    {
        if (isset($_GET['language_code'])) {
            $this->session->data['language'] = $_GET['language_code'];

            if (isset($this->request->get['redirect'])) {
                $this->redirect($this->request->get['redirect']);
            } else {
                $this->redirect($this->url->link('common/home'));
            }
        }
    }
}

?>